from django.contrib import admin

admin.site.site_header = 'XXX后台管理'  # 设置header
admin.site.site_title = 'XXX管理后台'   # 设置title
admin.site.index_title = 'XXX管理后台'
# 隐藏右侧SimpleUI广告链接和使用分析
SIMPLEUI_HOME_INFO = False
SIMPLEUI_ANALYSIS = False

from .models import Userinfo, UserDetail, Class, StuDetail, TeacherDetail
from .models import LessonInfo, StuGrade, StudentGroup, ClassLeader

# Register your models here.

class UserinfoAdmin(admin.ModelAdmin):
    list_display = ('uid', 'open_id', 'password')
    search_fields = ('uid', 'open_id')

class UserDetailAdmin(admin.ModelAdmin):
    list_display = ('uid', 'username', 'user_gender', 'user_birthday', 'user_notes')
    search_fields = ('username',)


class ClassAdmin(admin.ModelAdmin):
    list_display = ('class_name', 'class_teacher_id', 'class_notes')
    list_filter = ('class_teacher_id',)
    search_fields = ('class_name',)

class StuDetailAdmin(admin.ModelAdmin):
    list_display = ('uid', 'stu_num', 'stu_major', 'stu_notes', 'stu_class')
    list_filter = ('stu_class',)
    search_fields = ('stu_num',)

class TeacherDetailAdmin(admin.ModelAdmin):
    list_display = ('uid', 'teacher_num', 'teacher_notes')
    search_fields = ('teacher_num',)

class LessonInfoAdmin(admin.ModelAdmin):
    list_display = ('lesson_id', 'lesson_name', 'lesson_notes')
    search_fields = ('lesson_id', 'lesson_name')

class StuGradeAdmin(admin.ModelAdmin):
    list_display = ('uid', 'lesson_id', 'grade', 'semester')
    list_filter = ('semester',)
    search_fields = ('uid__uid', 'lesson_id__lesson_name')

class StudentGroupAdmin(admin.ModelAdmin):
    list_display = ('group_id', 'group_description',"belongs_to_class")
    search_fields = ('group_id',)


admin.site.register(Userinfo, UserinfoAdmin)
admin.site.register(UserDetail, UserDetailAdmin)
admin.site.register(Class, ClassAdmin)
admin.site.register(StuDetail, StuDetailAdmin)
admin.site.register(TeacherDetail, TeacherDetailAdmin)
admin.site.register(LessonInfo, LessonInfoAdmin)
admin.site.register(StuGrade, StuGradeAdmin)
admin.site.register(StudentGroup, StudentGroupAdmin)

class ClassLeaderAdmin(admin.ModelAdmin):
    list_display = ('uid', 'class_name', 'position')
    list_filter = ('class_name',)
    search_fields = ('uid__username', 'class_name__class_name', 'position')

admin.site.register(ClassLeader, ClassLeaderAdmin)





